package ch.ethz.inf.shop.model;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;

import ch.ethz.inf.shop.Title;

public class RecipeItem {

	@Title(text = "Recipe Item ID", isVisible = false)
	final private int recipeItemId;

	@Title(text = "Product", isVisible = true)
	final private Product product;

	@Title(text = "Recipe", isVisible = false)
	final private Recipe recipe;

	@Title(text = "Amount", isVisible = true)
	final private int amount;

	@Title(text = "Price", isVisible = true)
	final private BigDecimal linePrice;

	public RecipeItem(int recipeItemId, Product product, Recipe recipe, int amount, BigDecimal linePrice) {
		super();
		this.recipeItemId = recipeItemId;
		this.product = product;
		this.recipe = recipe;
		this.amount = amount;
		this.linePrice = linePrice;
	}

	public RecipeItem(final ResultSet rs, Recipe recipe) throws SQLException {
		this.recipe = recipe;
		this.amount = rs.getInt("amount");
		this.recipeItemId = rs.getInt("recipe_item_id");
		this.product = new Product(rs);
		this.linePrice = rs.getBigDecimal("price");
	}

	public int getRecipeItemId() {
		return recipeItemId;
	}

	public Product getProduct() {
		return product;
	}

	public Recipe getRecipe() {
		return recipe;
	}

	public int getAmount() {
		return amount;
	}

	public String getName() {
		return product.getName();
	}

	public int getProductId() {
		return product.getProductId();
	}

	public int getWeight() {
		return product.getWeight();
	}

	public String getCountryOfOrigin() {
		return product.getCountryOfOrigin();
	}

	public Category getCategory() {
		return product.getCategory();
	}

	public Brand getBrand() {
		return product.getBrand();
	}

	public BigDecimal getLinePrice() {
		return linePrice;

	}
}
